<template>
  <van-loading class="loading" v-if="show" size="24px" vertical>{{ text }}</van-loading>
  <van-overlay @click="closeHandle" :show="show" />
</template>

<script setup>
const emits = defineEmits(['update:show'])
const props = defineProps({
  text: {
    type: String,
    default: '加载中...',
  },
  show: {
    type: Boolean,
    default: false,
  },
  closeAble: {
    type: Boolean,
    default: false,
  },
})
const closeHandle = () => {
  if (!props.closeAble) return
  emits('update:show', false)
}
</script>

<style lang="scss" scoped>
.loading {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 2;
  transform: translate(-50%, -50%);
}
</style>
